#pragma once

#include <libge/libge.h>
#include "Location.h"
#include "slot.h"

class Client;

class Entity {
public:
	Entity(Client* cli);
	Entity(Client* cli, int _id);
	Entity(Client* cli, int _id, int _type);
	
	void Update(double t, double dt);
	void UpdateLocation();
	void ResetForces(bool x = true, bool y = true, bool z = true);
	void ApplyForce(double x, double y, double z);
	void SetBrakeFactor(double x, double y, double z);
	ge_Vector3d* getForces();
	ge_RK4State* getPhysicState();
	
	void setMoved(bool m);
	bool hasMoved();
	int getId();
	void setId(int _id);
	int getType();
	void setType(int t);
	bool isLiving();
	bool isObject();
	void setLiving(bool l);
	Location& getLocation();
	void setLocation(Location loc);
	void setVelocity(float vx, float vy, float vz);
	ge_Vector3f getVelocity();
	Metadata* getMetadata();
	bool isFlying();
	void setFlying(bool fly);
	bool isOnGround();
	void setOnGround(bool on);
	char* getName();
	void setName(char* s);
	void Animate(float dt);
	float getAnimationSpeed();
	void setAnimationSpeed(float s);
	float getAnimationTick();

protected:
	Client* client;
	bool moved;
	int id;
	int type;
	Location location;
	ge_Vector3f velocity;
	ge_Vector3f brake;
	Metadata meta[64];
	bool flying;
	bool onGround;
	bool living;
	char name[64];
	ge_RK4State physicState;
	ge_Vector3d forces;
	float animSpeed;
	float animTick;
};

#define ENTITY_BOAT 1
#define ENTITY_ITEM_STACK 2
#define ENTITY_MINECART 10
#define ENTITY_MINECART_STORAGE 11
#define ENTITY_MINECART_POWERED 12
#define ENTITY_ACTIVE_TNT 50
#define ENTITY_ENDER_CRYSTAL 51
#define ENTITY_ARROW 60
#define ENTITY_SNOWBALL 61
#define ENTITY_EGG 62
#define ENTITY_THROWN_ENDERPEAL 65
#define ENTITY_WITHER_SKULL 66
#define ENTITY_FALLING_OBJECTS 70
#define ENTITY_ITEM_FRAMES 71
#define ENTITY_ENDER_EYE 72
#define ENTITY_THROWN_POTION 73
#define ENTITY_FALLING_DRAGON_EGG 74
#define ENTITY_THROWN_EXP_BOTTLE 75
#define ENTITY_FISHING_FLOAT 90
#define ENTITY_PAINTING 100

#define ENTITY_PLAYER 1
#define ENTITY_CREEPER 50
#define ENTITY_SKELETON 51
#define ENTITY_SPIDER 52
#define ENTITY_GIANT_ZOMBIE 53
#define ENTITY_ZOMBIE 54
#define ENTITY_SLIME 55
#define ENTITY_GHAST 56
#define ENTITY_ZOMBIE_PIGMAN 57
#define ENTITY_ENDERMAN 58
#define ENTITY_CAVE_SPIDER 59
#define ENTITY_SIVLERFISH 60
#define ENTITY_BLAZE 61
#define ENTITY_MAGMA_CUBE 62
#define ENTITY_ENDER_DRAGON 63
#define ENTITY_WITHER 64
#define ENTITY_BAT 65
#define ENTITY_WITCH 66
#define ENTITY_PIG 90
#define ENTITY_SHEEP 91
#define ENTITY_COW 92
#define ENTITY_CHICKEN 93
#define ENTITY_SQUID 94
#define ENTITY_WOLF 95
#define ENTITY_MOOSHROOM 96
#define ENTITY_SNOWMAN 97
#define ENTITY_OCELOT 98
#define ENTITY_IRON_GOLEM 99
#define ENTITY_VILLAGER 120
